<?php

require("../../public/common.php");

checkLogin();

if (empty($_POST['id'])) return;

$id = $_POST['id'];

$name = $_POST['name'];

$title = $_POST['title'];

$domain = $_POST['domain'];

$pc_url = $_POST['pc_url'];

$keyword = $_POST['keyword'];

$content_url = $_POST['content_url'];

$mobile_url = $_POST['mobile_url'];

$time = date('Y-m-d H:i:s');

$query = mysqli_query($connect, "update template set name='{$name}',title='{$title}',domain='{$domain}',pc_url='{$pc_url}',keyword='{$keyword}',mobile_url='{$mobile_url}',content_url='{$content_url}' where id={$id};");

if (!$query)exit;

$ip = get_server_ip();

$user = $_SESSION["user"];

$query_history = mysqli_query($connect, "insert into history values(null,'{$ip}','{$user}','{$title}','{$domain}','{$keyword}','修改','{$pc_url}','{$mobile_url}','{$content_url}','{$time}');");

if (!$query_history)exit;

header('Location:../../views/index/index.php');
